package com.cjj.service.impl;

import com.cjj.service.TemplateManagementService;
import com.cjj.vo.InterveneVo;
import com.cjj.vo.TBodyTypeVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.mapper.*;
import com.guigu.pojo.THealthPlan;
import com.guigu.pojo.TInterveneModel;
import com.guigu.pojo.TMeals;
import com.guigu.pojo.TSportsItemLibrary;
import com.guigu.viwe.PageVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class TemplateManagementServiceImpl implements TemplateManagementService {

    @Resource
    private TInterveneModelMapper tInterveneModelMapper;

    @Resource
    private TSportsItemLibraryMapper tSportsItemLibraryMapper;

    @Resource
    private TMealsMapper tMealsMapper;

    @Resource
    private THealthPlanMapper tHealthPlanMapper;

    //分页查询
    @Override
    public PageInfo<TInterveneModel> queryTemplateManagement(PageVo<TInterveneModel> pageVo) {
        PageHelper.startPage(pageVo.getCurrentPage(), pageVo.getPageSize());
        PageInfo<TInterveneModel> tInterveneModelPageInfo = new PageInfo<>(this.tInterveneModelMapper.queryTemplateManagement(pageVo.getCondition()));
        return tInterveneModelPageInfo;
    }

    // 查询饮食运动干预
    @Override
    public InterveneVo queryIntervene() {
        List<THealthPlan> tHealthPlans = this.tHealthPlanMapper.selectAll();
        List<TMeals> tMeals = this.tMealsMapper.selectAll();
        List<TSportsItemLibrary> tSportsItemLibraries = this.tSportsItemLibraryMapper.selectAll();
        return new InterveneVo(tMeals, tSportsItemLibraries, tHealthPlans);
    }

    @Override
    public int addOnSubmit(TInterveneModel tInterveneModel) {
        return this.tInterveneModelMapper.insertSelective(tInterveneModel);
    }

    @Override
    public int DisableEnable(Map map) {

        return this.tInterveneModelMapper.DisableEnable(map);
    }

    @Override
    public int updateTemplat(TInterveneModel tInterveneModel) {
        return this.tInterveneModelMapper.updateByPrimaryKeySelective(tInterveneModel);
    }


}
